package com.lan.mock13.shengsai.tH;

import java.util.*;

class Node {
	public int val;
	public int t;
	
	public Node(int val, int t) {
		this.val = val;
		this.t = t;
	}
}


public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int m = input.nextInt();
		PriorityQueue<Node> queue = new PriorityQueue<Node>((a, b)->{
			return b.val - a.val;
		});
		for (int i = 0; i < n; i ++) {
			int val = input.nextInt();
			int t = input.nextInt();
			queue.offer(new Node(val, t));
		}
		long res = 0;
		for (int i = 0; i < m; i ++) {
			
			if (queue.isEmpty()) {
				break;
			} else {
				Node node = queue.poll();
				res += node.val;
				if (node.val - node.t > 0) {
					queue.offer(new Node(node.val - node.t, node.t));
				}
			}
		}
		System.out.println(res);
		
	}
}
